﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using PulseLibrary;
using PulseLibrary.GUIControls;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace PulsePrototype.GameStates
{
    public class TitleScreen : BaseGameState
    {
        PictureBox backgroundImage;
        LinkLabel startLabel;

        public TitleScreen(Game game, GameStateManager manager)
            : base(game, manager)
        {
        }

        protected override void LoadContent()
        {
            ContentManager Content = GameRef.Content;
            Texture2D background = Content.Load<Texture2D>(@"Background\blue11");
            base.LoadContent();

            backgroundImage = new PictureBox(background, GameRef.ScreenRectangle);

            startLabel = CreateStartLabel();
            startLabel.Text = "Press Enter To Start";

            controlManager.Add(backgroundImage);
            controlManager.Add(startLabel);
        }

        private LinkLabel CreateStartLabel()
        {
            LinkLabel newLabel;

            newLabel = new LinkLabel();
            newLabel.Position = new Vector2(0, 0);
            newLabel.Text = "Menu Item";
            newLabel.Color = Color.White;
            newLabel.TabStop = true;
            newLabel.HasFocus = true;
            newLabel.Selected += new EventHandler(startLabel_Selected);

            return newLabel;
        }

        public override void Update(GameTime gameTime)
        {
            controlManager.Update(gameTime, PlayerIndex.One);
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            GameRef.SpriteBatch.Begin();

            base.Draw(gameTime);
            controlManager.Draw(GameRef.SpriteBatch);

            GameRef.SpriteBatch.End();
        }

        private void startLabel_Selected(object sender, EventArgs e)
        {
            stateManager.PushState(GameRef.StartMenuScreen1);
        }
    }
}
